home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / e-lang / nodemstr.lha / nodemaster / examples / NodeMaster_Example.e
Text File  |  1996-04-11  |  4KB  |  103 lines

  1. /*
  2. ** NodeMaster_Example n. 1
  3. **
  4. ** (C)1995/96 By Fabio Rotondo
  5. **
  6. ** This code is placed in the Public Domain.
  7. ** It is intended FOR demostration of NodeMaster only.
  8. **
  9. ** Feel free of examine, modify AND DO whatever you want!
  10. **
  11. */
  12.  
  13. /*
  14. ** DESCRIPTION:
  15. **
  16. ** NodeMaster can HANDLE Exec Lists of everything.
  17. **
  18. ** Just TO show its power, you'll see a way of creating
  19. ** multiwindows application relying on Wouter's EasyGUI AND
  20. ** my NodeMaster. This application is quite complicated AND I'll try TO
  21. ** explain it in the better way I can. ;)
  22. */
  23. OPT OSVERSION = 37
  24.  
  25. MODULE 'fabio/nodemaster_oo',               -> This is OUR MODULE
  26.        'tools/exceptions', 'tools/easygui'  -> tools/exceptions are FOR
  27.                                             -> report_exception() PROC AND
  28.                                             -> 'tools/easygui'... GUESS!
  29.  
  30. DEF nm:PTR TO nodemaster -> This is an hinstance of our NodeMaster
  31. DEF quit=FALSE           -> a quitvar... 8)
  32.  
  33. PROC main() HANDLE       -> Please, note: HANDLE keyword FOR EXCEPTIONS handling
  34.   NEW nm.nodemaster()    -> Here we setup our OBJECT.
  35.  
  36.   dogui()                -> we MUST have at least one gui!
  37.  
  38.   REPEAT                 -> We will hear FOR GUI events
  39.     multiwait()          -> (Of multiple windows ;) ...
  40.   UNTIL quit = TRUE      -> UNTIL QUIT is set TO TRUE
  41.  
  42. EXCEPT DO                -> In CASE of some problems... (OR just TO quit)
  43.   report_exception()     -> Here there is a brief explanation
  44.   END nm                 -> Remeber ALWAYS TO END a OBJECT!!!
  45.   CleanUp(0)             -> Let's keep things clean...
  46. ENDPROC
  47.  
  48. PROC dogui() HANDLE      -> This PROC creates a GUI on the WB screen
  49.   DEF gh=NIL:PTR TO guihandle -> a guihandle (NOTE: It is LOCAL! ;)
  50.  
  51.   gh:=guiinit('NEW EasyGUI Window!',
  52.               [EQROWS,
  53.                 [SBUTTON, {dogui}, 'Create!'],  -> This button just call dogui() again!
  54.                 [BAR],
  55.                 [SBUTTON, {closeall},'Quit!']   -> This will quit ALL!
  56.               ])
  57.  
  58.   nm.add(gh)     -> Here we add this GUI_handle TO our NodeMaster OBJECT
  59.   Wait(gh.sig)   -> AND wait FOR this window's first signal
  60.  
  61. EXCEPT           -> In CASE of any error
  62.   remgui(gh)     -> we remove THIS window from thje Windows LIST
  63.   ReThrow()      -> AND rethrow() error one level up!
  64. ENDPROC
  65.  
  66. PROC multiwait()  -> This is one of the most important PROCS!
  67.   DEF gh:PTR TO guihandle -> Another LOCAL gui_handle var!
  68.   DEF res                 -> Here we store Window event value...
  69.  
  70.   IF nm.first()   -> Let's start from the first GUI_handler we have stored...
  71.     REPEAT
  72.       gh:=nm.obj()  -> Here we set our gh TO original GUI_handler
  73.       res:=guimessage(gh) -> We get one message
  74.       IF res>=0           -> AND eventually close this GUI window
  75.         remgui(gh)
  76.       ENDIF
  77.     UNTIL nm.succ() = FALSE  -> Now we JUMP TO the next one
  78.   ENDIF
  79. ENDPROC
  80.  
  81. PROC closeall(i=0) -> This PROC just close ALL opened windows
  82.  
  83.   IF nm.first() -> We start from the first
  84.     REPEAT
  85.       cleangui(nm.obj())    -> we clear things up
  86.     UNTIL nm.succ() = FALSE  -> AND get the next
  87.   ENDIF
  88.  
  89.   quit := TRUE  -> Here we set the QUIT var TO TRUE
  90. ENDPROC
  91.  
  92. PROC remgui(gh:PTR TO guihandle) -> This PROC remove just one desired gui
  93.   IF nm.first()                  -> Here we scan LIST from the first
  94.     REPEAT
  95.       IF gh = nm.obj()           -> IF the current item is exactly the one we want
  96.         nm.del()                 -> We remove the item from the LIST
  97.         cleangui(gh)             -> AND clear the interface
  98.         RETURN                   -> THEN exit without ending the LOOP
  99.       ENDIF
  100.     UNTIL nm.succ() = FALSE      -> Here we look FOR the next item...
  101.   ENDIF
  102. ENDPROC
  103.